#include <vector>
#include <map>

#include "VoltageTrace.h"
#include "PowerModel.h"

#define CAP_FUDGE_FACTOR 5 // increasing this increases capacitor drain speed

#define CAP_LOG_EVERY 1000000 // log a message every N tick()s

typedef enum {
  MODE_ACTIVE,
  MODE_SLEEPING,
  MODE_OFF,
} capacitor_powermode_t;

class CapacitorPowerModel : public PowerModel{
  VoltageTrace *vtrace;

public:

  //Electrical parameters
  double capacitance;    // in farads
  double minVoltage;     // min. operating voltage, in volts
  double resurrectionVoltage;  // min. voltage to charge up to, in volts
  double initialVoltage; // in volts
  double resistance;     // in ohms
  double voltage;        // instantaneous voltage, in volts
  std::map<capacitor_powermode_t, double> modeResistances;

  bool currentlyDead;
  unsigned long currDeathTickCount;

  //Constructor
  CapacitorPowerModel();

  //Reports the model's name as a string
  virtual char *Identify();

  //Reports the summary stats for the simulation
  virtual void dumpStats(FILE *f);

  virtual PowerModel::QueryResult *tick(unsigned long currentTick);
  virtual PowerModel::QueryResult *tick(unsigned long currentTick, float powerInWatts);
  

  void setPowerMode(capacitor_powermode_t newMode);

  //Destructor
  ~CapacitorPowerModel();

};
